package functii;

import main.Functie;
import operatori.Cat;

public final class Arctg extends Functie {

	@Override
	public double calculDerivata() {
		if (getfStang() == null)
			System.exit(1);
		return Cat.Calcul(getfStang().calculDerivata(),1+Math.pow(getfStang().calcul(), 2));
	}

	@Override
	public String derivare() {
		if (getfStang() == null)
			System.exit(1);
		return Cat.concatTermens(getfStang().derivare(),"(1+"+getfStang().toString()+"^2)");		
	}

	@Override
	public String toString() {
		if (getfStang() == null)
			System.exit(1);
		return concatTermeni(getfStang().toString());
	}

	@Override
	public double calcul(double aux1) {
		return Math.atan(aux1);
	}
	
	public static double Calcul(double aux1) {
		return Math.atan(aux1);
	}

	@Override
	public String concatTermeni(String aux1) {
		String aux;
		int nrP;
		nrP = aux1.charAt(0) == '(' ? 0 : 2;
		aux = "arctg";
		if (nrP != 0) aux += "(";
		aux += aux1;
		if (nrP != 0) aux += ")";
		return aux;
	}
	
	public static String concatTermens(String aux1) {
		String aux;
		int nrP;
		nrP = aux1.charAt(0) == '(' ? 0 : 2;
		aux = "arctg";
		if (nrP != 0) aux += "(";
		aux += aux1;
		if (nrP != 0) aux += ")";
		return aux;
	}
	
	public double calculeazaValoare() {
		return this.calcul();
	}

}
